import { createStore, combineReducers, applyMiddleware } from "redux";
import thunk from "redux-thunk";
import { actionLog } from "./middlewares/actionLog";
import languageReducer from "./language/languageReducer";
import recommendProducts from "./recommendProducts/recommendProductsReducer";
import { languageMiddleware } from "./middlewares/languageMiddleware";

// combineReducers 捆绑起来，统一成root
const rootReducer = combineReducers({
  language: languageReducer,
  recommendProducts: recommendProducts,
});

const store = createStore(rootReducer, applyMiddleware(thunk, actionLog,languageMiddleware));

export type RootState = ReturnType<typeof store.getState>; // 映射store类型
export default store;
